'use strict';
const db = uniCloud.database()
exports.main = async (event, context) => {
	
	const res_clinic = await db.collection('rx-users-clinic').where({ userId: event.userId, types: event.types }).get()
	const newArray = res_clinic.data[0].clinic.filter(item => item !== event.clinicId)
	
	// 取消关联诊所
	await db.collection('rx-users-clinic').where({ userId: event.userId, types: event.types }).update({ clinic: newArray })
	
	//返回数据给客户端
	return { data: {}, code: 200, msg: 'ok.' }
};
